<?php

define('FPDF_FONTPATH','font/');


require('chinese-unicode.php'); 


$init=array(215.9,93.1);

$pdf=new PDF_Unicode('UTF-8','L','mm',$init); 
$pdf->Open(); 
$pdf->AddUniGBhwFont('simhei','黑体'); 
$pdf->AddUniGBhwFont('simsun','宋体'); 
//$pdf->SetFont('uni','',20); 

$pdf->Open(); 
$pdf->AddPage(); 


//$pdf->AddGBhwFont('simhei','黑体'); 
//$pdf->AddGBhwFont('simsun','宋体'); 
$pdf->SetMargins(5,8,5); 
$pdf->SetFont('simhei','','12'); 
$pdf->SetXY(7,5); 
$pdf->Text(7,8,'振兴市政水电费通知单');
$pdf->Text(180,8,'2011年7月');
$pdf->Line(7,9,210,9);
$pdf->SetXY(7,10);
$header=array('Name','Age','Sex','Salary'); //设置表头
$data=array(); //设置表体
$data[0] = array('Simon','24','Male','5,000.00');
$data[1] = array('Elaine','25','Female','6,000.00');
$data[2] = array('Susan','25','Female','7,000.00');
$data[3] = array('David','26','Male','8,000.00');
$width=array(45,45,45,45); //设置每列宽度
$pdf->SetFont('simsun','','12'); 
for($i=0;$i<count($header);$i++) //循环输出表头
$pdf->Cell($width[$i],6,$header[$i],1);
$pdf->Ln();

foreach($data as $row) //循环输出表体
{
	$pdf->SetX(7);
$pdf->Cell($width[0],6,$row[0],1);
$pdf->Cell($width[1],6,$row[1],1);
$pdf->Cell($width[2],6,$row[2],1);
$pdf->Cell($width[3],6,$row[3],1);
$pdf->Ln();
}


//$pdf->IncludeJS("print({bUI: false,bSilent: true,bShrinkToFit: false});closeDoc();"); 
//$pdf->Output(); //输出PDF 到浏览器

$pdf->Output('foobar.pdf','I'); 
?>